Program to insert the values into a table by reading values

import java.sql.*;
public class Insert
{
public static void main(String args[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:vision","scott","tiger");
Statement st=con.createStatement();
String mna;
int meno,msal;
Scanner read=new Scanner(System.in);
int ch=’y’;
while(((char)ch)!=’n’)
{
System.out.println("Enter Empno,name,Salary");
meno=read.nextInt();
mna=read.nextLine();
msal=read.nextInt();
String qry="insert into abc
values("+meno+",'"+mna+"',"+msal+")";
st.executeUpdate(qry);
System.out.println(“Continue Y/n”);
ch=read.nextInt();
}

                }
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}

Program to Update the salary for the givien employ number?

import java.sql.*;
import java.util.Scanner;
public class UpdateEmp
{
public static void main(String args[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:vision","scott","tiger");
Statement st=con.createStatement();
Scanner read=new Scanner(System.in);
int meno;
System.out.println(“Enter Employ no ..”);
meno=read.nextInt();
st.executeUpdate(“update abc set sal=sal+1000 where eno=”+meno);                      
System.out.println("Row Updated");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}

Program to Delete the row for the given employ no
import java.sql.*;
import java.util.Scanner;
public class UpdateEmp
{
public static void main(String args[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:vision","scott","tiger");
Statement st=con.createStatement();
Scanner read=new Scanner(System.in);
int meno;
System.out.println(“Enter Employ no to delete…..”);
meno=read.nextInt();
st.executeUpdate(“delete from abc where eno=”+meno);                      
System.out.println("Row Deleted");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}

Program to retrieve the record from a table to the given employ no.

import java.sql.*;
public class Insert
{
public static void main(String args[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:vision","scott","tiger");
Statement st=con.createStatement();
Scanner read=new Scanner(System.in);
int meno;
System.out.println(“Enter Employ no to Display”);
meno=read.nextInt();
ResultSet rs=st.executeQuery(“select * from abc where eno=”+meno);
while(rs.next())
{
System.out.println(rs.nextInt(1)+” “+rs.nextString(2)+” “+
rs.nextInt(3));
}
rs.close();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}